﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class ctrLeft : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        BZZ.DataAcess woker = new BZZ.DataAcess();
        string sql = "select id,realname from professor where not (cata='篆刻' and isagent='0') order by id desc";
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        DataSet dset = woker.Execute(sql);
        sb.Append("<table width=\"160\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\">");
        sb.Append("                <tr>");
        sb.Append("                  <td width=\"70\" height=\"10\" align=\"center\" class=\"zt04\"></td>");
        sb.Append("                  <td width=\"70\" align=\"center\" class=\"zt04\"></td>");
        sb.Append("                </tr>");
        for (int i = 0; i < dset.Tables[0].Rows.Count; i++)
        {
            DataRow row = dset.Tables[0].Rows[i];
            string id = row["id"].ToString();
            string realname = row["realname"].ToString();

            string id2 = "0";
            string realname2 = "";
            i++;
            if (i < dset.Tables[0].Rows.Count)
            {
                row = dset.Tables[0].Rows[i];
                id2 = row["id"].ToString();
                realname2 = row["realname"].ToString();
            }
            sb.Append("                <tr>");
            sb.Append("                  <td align=\"left\" class=\"zt01\">·<a href='professorDetail.aspx?id=" + id + "'>" + realname + "</a> </td>");
            sb.Append("                  <td align=\"left\" class=\"zt01\">·<a href='professorDetail.aspx?id=" + id2 + "'>" + realname2 + "</a> </td>");
            sb.Append("                </tr>");


        }
        sb.Append("                <tr>");
        sb.Append("                  <td height=\"10\" colspan=\"2\" align=\"left\" class=\"zt01\">");
        sb.Append("				  </td>");
        sb.Append("                  </tr>");
        sb.Append("            </table>");
        litLeftProfessor.Text = sb.ToString();

        if (!IsPostBack)
        {
            string key = Request.QueryString["k"];
            string t = Request.QueryString["t"];
            if (t != null)
            {
                ddlProductCata.SelectedValue = t;
                txtKeyWord.Text = key;
            }

        }
    }
    protected void btnQuery_Click(object sender, ImageClickEventArgs e)
    {
        string cata = ddlProductCata.SelectedValue;
        string keword = txtKeyWord.Text.Trim();
        keword = LIB.Filter.inputFilter(keword);
        string gotoUrl = "query.aspx?t="+cata+"&k="+Server.UrlEncode(keword);
        Response.Redirect(gotoUrl);
        //Server.Transfer("query.aspx");
        return;

        //string url = "";
        //switch (cata)
        //{
        //    case "1":
        //        url = "Traditionalpainting.aspx";
        //        break;
        //    case "2":
        //        url = "Calligraphy.aspx";
        //        break;
        //    case "3":
        //        url = "Seal.aspx";
        //        break;
        //}
        //Response.Redirect(url + "?k=" + this.Server.UrlEncode(keword));
        //Response.End();


    }
}
